/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package JFreeChartExtensions.chartextensions.customsaveas;

import JFreeChartExtensions.chartextensions.AbstractChartPanelExtension;
import JFreeChartExtensions.ExtendableChartPanel;
import JFreeChartExtensions.JChartMenu.ChartMenuListeners.SaveAsListener;
import JFreeChartExtensions.JChartMenu.JChartMenu;
import org.jfree.chart.ChartPanel;

/**
 *
 * @author Nobody
 */
public class CustomSaveAsExtension extends AbstractChartPanelExtension {

    private JChartMenu setScaleMenuItem;

    public CustomSaveAsExtension(ExtendableChartPanel panel) {
        super(panel);
        name = "CustomSaveAsExtension";
    }

    @Override
    public void applyExtension(ChartPanel chartPanel) {
        this.chartPanel = (ExtendableChartPanel) chartPanel;

        setScaleMenuItem = new JChartMenu("Save As...");
        setScaleMenuItem.addListener(new SaveAsListener( (ExtendableChartPanel) chartPanel));
        chartPanel.getPopupMenu().add(setScaleMenuItem);
    }

    @Override
    public void removeExtension() {
        chartPanel.getPopupMenu().remove(setScaleMenuItem);
    }
}
